package org.feng.service.impl;


import org.feng.entity.pojo.Resource;
import org.feng.mapper.ResourceMapper;
import org.feng.service.ResourceService;
import lombok.AllArgsConstructor;
import org.feng.serive.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 资源表 服务实现类
 * </p>
 *
 * @author feng
 * @since 2021-11-30
 */
@Service
@AllArgsConstructor
public class ResourceServiceImpl extends BaseServiceImpl<ResourceMapper, Resource> implements ResourceService {
    private final ResourceMapper resourceMapper;

    @Override
    public void open(Resource resource) {
        if (resource.getOpen() == 1) {
            List<Resource> list = this.list();
            for (Resource resource1 : list) {
                resource1.setOpen(0);
            }
            this.updateBatchById(list);
        }
        this.updateById(resource);
    }
}
